iconhelper: Move size computation
authorBenjamin Otte <otte@redhat.com>
Fri, 27 Nov 2015 17:05:36 +0000 (18:05 +0100)
committerBenjamin Otte <otte@redhat.com>
Tue, 1 Dec 2015 23:29:29 +0000 (00:29 +0100)
We do a switch on the image type, so compute the size for a certain
image type right there.

gtk/gtkiconhelper.c

index f71c464df5854b70ce7cb8b35de66b538d5d71c1..d4b5aa0b238a2488268dd0e0cf538fad8eabf576 100644 (file)
@@ -867,6 +867,14 @@ _gtk_icon_helper_get_size (GtkIconHelper *self,
       height = (height + scale - 1) / scale;
       break;
 
+    case GTK_IMAGE_ANIMATION:
+      {
+        GdkPixbufAnimation *animation = gtk_image_definition_get_animation (self->priv->def);
+        width = gdk_pixbuf_animation_get_width (animation);
+        height = gdk_pixbuf_animation_get_height (animation);
+        break;
+      }
+
     case GTK_IMAGE_ICON_NAME:
     case GTK_IMAGE_GICON:
       if (self->priv->pixel_size != -1 || self->priv->force_scale_pixbuf)
@@ -876,7 +884,6 @@ _gtk_icon_helper_get_size (GtkIconHelper *self,
 
     case GTK_IMAGE_STOCK:
     case GTK_IMAGE_ICON_SET:
-    case GTK_IMAGE_ANIMATION:
     case GTK_IMAGE_EMPTY:
     default:
       break;
@@ -893,12 +900,6 @@ _gtk_icon_helper_get_size (GtkIconHelper *self,
           height = self->priv->rendered_surface_height;
           cairo_surface_destroy (surface);
         }
-      else if (gtk_image_definition_get_storage_type (self->priv->def) == GTK_IMAGE_ANIMATION)
-        {
-          GdkPixbufAnimation *animation = gtk_image_definition_get_animation (self->priv->def);
-          width = gdk_pixbuf_animation_get_width (animation);
-          height = gdk_pixbuf_animation_get_height (animation);
-        }
       else if (self->priv->icon_size != GTK_ICON_SIZE_INVALID)
         {
           ensure_icon_size (self, &width, &height);